//
//  ZFBBusinessTypeCell.m
//  ZFBCollectionDemo
//
//  Created by Apple on 2018/3/25.
//  Copyright © 2018年 techbird. All rights reserved.
//

#import "ZFBBusinessTypeCell.h"
#import "UILabel+Addition.h"
#import "Masonry.h"

@interface ZFBBusinessTypeCell()
@property (nonatomic,strong)UIImageView *imageView;
@property (nonatomic,strong)UILabel *label;
@end

@implementation ZFBBusinessTypeCell

//重写这个方法是因为控件支持从NIB创建
-(void)awakeFromNib{
    [super awakeFromNib];
    [self setupUI];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

-(void)setupUI{
    UIImageView *imageView = [[UIImageView alloc]init];
    [self.contentView addSubview:imageView];
    _imageView = imageView;
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        make.centerY.offset(-10);
        make.width.height.offset(35);
    }];
    
    UILabel *label = [UILabel makeLabelWithTextColor:[UIColor darkGrayColor] andTextFontSize:15 andText:@"物流"];
    [self.contentView addSubview:label];
    _label = label;
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        make.centerY.offset(20);
    }];
}

-(void)setBusinessType:(ZFBBusinessType *)businessType{
    _businessType = businessType;
    _imageView.image = [UIImage imageNamed:businessType.icon];
    _label.text = businessType.name;
}

-(void)setHighlighted:(BOOL)highlighted{
    [super setHighlighted:highlighted];
    self.backgroundColor = highlighted?[UIColor colorWithWhite:0.7 alpha:1]:[UIColor whiteColor];
}
@end
